package com.example.admin.brainwave.ui.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.admin.brainwave.R;
import com.example.admin.brainwave.bean.BeaconDevice;

import java.util.List;

public class PairAdapter extends BaseQuickAdapter<BeaconDevice, BaseViewHolder> {


    public PairAdapter(int layoutResId, @Nullable List<BeaconDevice> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeaconDevice item) {
        TextView name = helper.getView(R.id.tv_item_pair_name);
        TextView state = helper.getView(R.id.iv_item_pair_state);
        state.setText(mContext.getResources().getString(R.string.paired));
        if (item.isConnect()) {
            state.setText(mContext.getResources().getString(R.string.connect));
        }
        if (!TextUtils.isEmpty(item.getName())) {
            name.setText(item.getName());
        } else {
            name.setText(item.getAddress());
        }
    }
}
